home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1998 January
/
Macworld (1998-01).dmg
/
Serious Demos
/
Visual MacStandardBasic Demo
/
Samples
/
Calculator Demo
/
Form1
< prev
Wrap
Text File
|
1997-10-20
|
8KB
|
523 lines
MacStandardBasic Form Version 3.0
FormBegin
Name=Form1
Title=Calculator Demo
Left=100
Top=50
Width=234
Height=263
Sub Proc.=Form1_Event
Visible=1
Style=10
Font=Geneva
FontSize=12
FontStyle=0
Show Grid=0
Grid Snap=1
Grid Size=8
Min. Width=100
Max. Width=2000
Min. Height=100
Max. Height=2000
AutoCenter=0
ForeColor=0 0 0
BackColor=22413 22415 49806
FormEnd
ControlBegin=TextBox
Name=TextBox1
Text=
Left (x)=16
Top (y)=24
Width=192
Height=32
Sub Proc.=TextBox1_Event
Visible=1
Value=1
Enabled=0
Font=Chicago
FontSize=20
FontStyle=1
ScrollBar=0
Read Only=1
Opt20=1
Frame=1
ForeColor=0 0 0
BackColor=65535 65535 65535
ControlEnd
ControlBegin=Button
Name=Button1
Text=7
Left (x)=16
Top (y)=72
Width=32
Height=32
Sub Proc.=Button1_Click
Visible=1
Value=0
Enabled=1
Opt20=1
ControlEnd
ControlBegin=Button
Name=Button2
Text=8
Left (x)=56
Top (y)=72
Width=32
Height=32
Sub Proc.=Button2_Click
Visible=1
Value=0
Enabled=1
Opt20=2
ControlEnd
ControlBegin=Button
Name=Button3
Text=9
Left (x)=96
Top (y)=72
Width=32
Height=32
Sub Proc.=Button3_Click
Visible=1
Value=0
Enabled=1
Opt20=3
ControlEnd
ControlBegin=Button
Name=Button4
Text=*
Left (x)=136
Top (y)=72
Width=32
Height=32
Sub Proc.=Button4_Click
Visible=1
Value=0
Enabled=1
Opt20=4
ControlEnd
ControlBegin=Button
Name=Button5
Text=4
Left (x)=16
Top (y)=112
Width=33
Height=33
Sub Proc.=Button5_Click
Visible=1
Value=0
Enabled=1
Opt20=5
ControlEnd
ControlBegin=Button
Name=Button6
Text=5
Left (x)=56
Top (y)=112
Width=33
Height=33
Sub Proc.=Button6_Click
Visible=1
Value=0
Enabled=1
Opt20=6
ControlEnd
ControlBegin=Button
Name=Button7
Text=6
Left (x)=96
Top (y)=112
Width=33
Height=33
Sub Proc.=Button7_Click
Visible=1
Value=0
Enabled=1
Opt20=7
ControlEnd
ControlBegin=Button
Name=Button8
Text=-
Left (x)=136
Top (y)=112
Width=33
Height=33
Sub Proc.=Button8_Click
Visible=1
Value=0
Enabled=1
Opt20=8
ControlEnd
ControlBegin=Button
Name=Button9
Text=/
Left (x)=176
Top (y)=72
Width=32
Height=32
Sub Proc.=Button9_Click
Visible=1
Value=0
Enabled=1
Opt20=9
ControlEnd
ControlBegin=Button
Name=Button10
Text=1
Left (x)=16
Top (y)=152
Width=33
Height=33
Sub Proc.=Button10_Click
Visible=1
Value=0
Enabled=1
Opt20=10
ControlEnd
ControlBegin=Button
Name=Button11
Text=2
Left (x)=56
Top (y)=152
Width=33
Height=33
Sub Proc.=Button11_Click
Visible=1
Value=0
Enabled=1
Opt20=11
ControlEnd
ControlBegin=Button
Name=Button12
Text=3
Left (x)=96
Top (y)=152
Width=33
Height=33
Sub Proc.=Button12_Click
Visible=1
Value=0
Enabled=1
Opt20=12
ControlEnd
ControlBegin=Button
Name=Button13
Text=+
Left (x)=136
Top (y)=152
Width=32
Height=32
Sub Proc.=Button13_Click
Visible=1
Value=0
Enabled=1
Opt20=13
ControlEnd
ControlBegin=Button
Name=Button14
Text=C
Left (x)=176
Top (y)=152
Width=33
Height=33
Sub Proc.=Button14_Click
Visible=1
Value=0
Enabled=1
Opt20=14
ControlEnd
ControlBegin=Button
Name=Button15
Text=0
Left (x)=56
Top (y)=192
Width=33
Height=33
Sub Proc.=Button15_Click
Visible=1
Value=0
Enabled=1
Opt20=15
ControlEnd
ControlBegin=Button
Name=Button16
Text=.
Left (x)=96
Top (y)=192
Width=33
Height=33
Sub Proc.=Button16_Click
Visible=1
Value=0
Enabled=1
Opt20=16
ControlEnd
ControlBegin=Button
Name=Button17
Text=CE
Left (x)=176
Top (y)=112
Width=33
Height=33
Sub Proc.=Button17_Click
Visible=1
Value=0
Enabled=1
Opt20=17
ControlEnd
ControlBegin=Button
Name=Button18
Text==
Left (x)=136
Top (y)=192
Width=33
Height=33
Sub Proc.=Button18_Click
Visible=1
Value=0
Enabled=1
Opt20=18
ControlEnd
Global
Dim Total#, LastOp, Flag1
EndGlobal
Start
Dim A
CreateTheMenus
Form Form1
A=0
Do While A=0
Loop
Finish
Sub CreateTheMenus( )
MenuApple
MenuAddItem 1, "About Calculator Demo", "", AboutTheApp
MenuDesk
MenuAdd 2, "File", None
MenuAddItem 2, "Quit", "Q", QuitTheApp
EndSub
Sub QuitTheApp( )
End
EndSub
Sub AboutTheApp( )
Dim a
a = MsgBox ("Calculator Demo", 0)
EndSub
Sub Button14_Click( )
CtlText TextBox1, "",0
Total = 0
EndSub
Sub TextBox1_Event( )
EndSub
Sub Button1_Click( )
CtlText TextBox1, "7",Flag1
Flag1 = 1
EndSub
Sub Button2_Click( )
CtlText TextBox1, "8",Flag1
Flag1 = 1
EndSub
Sub Button3_Click( )
CtlText TextBox1, "9",Flag1
Flag1 = 1
EndSub
Sub Button5_Click( )
CtlText TextBox1, "4",Flag1
Flag1 = 1
EndSub
Sub Button6_Click( )
CtlText TextBox1, "5",Flag1
Flag1 = 1
EndSub
Sub Button7_Click( )
CtlText TextBox1, "6",Flag1
Flag1 = 3
EndSub
Sub Button10_Click( )
CtlText TextBox1, "1",Flag1
Flag1 = 1
EndSub
Sub Button11_Click( )
CtlText TextBox1, "2",Flag1
Flag1 = 1
EndSub
Sub Button12_Click( )
CtlText TextBox1, "3",Flag1
Flag1 = 1
EndSub
Sub Button15_Click( )
CtlText TextBox1, "0",Flag1
Flag1 = 1
EndSub
Sub Button16_Click( )
CtlText TextBox1, ".",Flag1
Flag1 = 1
EndSub
Sub Form1_Event( )
Dim Num$
If EventCode(0) = 21 Then End
' Let's check for keypress
If EventCode(0) = 26 Then
Num$ = Ucase( Chr( EventCode(2) ))
If Num$ >="0" and Num$ <="9" Then
CtlText TextBox1, Num$ ,Flag1
Flag1 = 1
Else
Select Num$
Case "."
CtlText TextBox1, Num$ ,Flag1
Flag1 = 1
Case "="
DoCalc
LastOp = 0
Case "+"
DoCalc
LastOp = 1
Case "-"
DoCalc
LastOp = 2
Case "*"
DoCalc
LastOp = 3
Case "/"
DoCalc
LastOp = 4
case "C"
CtlText TextBox1, "",0
Total = 0
EndCase
Endif
EndIf
EndSub
Sub Button13_Click( )
DoCalc
LastOp = 1
EndSub
Sub Button4_Click( )
DoCalc
LastOp = 3
EndSub
Sub Button8_Click( )
DoCalc
LastOp = 2
EndSub
Sub Button9_Click( )
DoCalc
LastOp = 4
EndSub
Sub DoCalc( )
Dim a#
If Flag1 = 0 Then ExitSub
Flag1 = 0
A = Val(CtlText( TextBox1 ))
Select LastOp
Case 0
Total = A
Case 1
Total =Total + A
Case 2
Total =Total - A
Case 3
Total =Total * A
Case 4
Total =Total / A
EndCase
CtlText TextBox1, Str( Total ), 0
EndSub
Sub Button17_Click( )
CtlText TextBox1, "", 0
EndSub
Sub Button18_Click( )
DoCalc
LastOp = 0
EndSub